const { defineConfig } = require('@vue/cli-service')
const { GuanceSourceMapUploadWebpackPlugin } = require('@cloudcare/webpack-plugin')

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: (config) => {
    // 为非开发环境引入 Sourcemap 上传插件
    if (process.env.NODE_ENV !== 'development') {
      config.plugins.push(
        new GuanceSourceMapUploadWebpackPlugin({
          applicationId: process.env.VUE_APP_CLOUDCARE_APPLICATION_ID,
          apiKey: process.env.VUE_APP_CLOUDCARE_API_KEY,
          server: process.env.VUE_APP_CLOUDCARE_SERVER,
          filepaths: ['dist/'],
          logLevel: 'verbose',
          root: '',
          env: process.env.VUE_APP_CLOUDCARE_ENV,
          version: process.env.VUE_APP_CLOUDCARE_VERSION,
        })
      )
    }
  }
})
